package com.dameng.jianyouquan.base.mvpBase;

import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.dameng.jianyouquan.base.BaseFragment;

public abstract class BaseMvpFragment<T extends BasePresenter> extends BaseFragment implements BaseView {

    protected T mPresenter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter=creatPresenter();
        mPresenter.attachView(this);
    }

    protected abstract T creatPresenter();

    @Override
    public void showToast(String msg) {
        Toast.makeText(getContext(),msg, Toast.LENGTH_SHORT).show();
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter!=null){
            mPresenter=null;
        }
    }

}
